package com.baturu.vin.hyundai.dal.dao;

import com.baturu.vin.hyundai.dto.HyundaiKiaImageInfoDTO;
import com.baturu.vin.hyundai.dto.KiaPartsDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface HyundaiKiaImageDAO {

    @Select("<script>" +
            "SELECT crnm,bpno,startTime,endTime,finalPartsCode,finalPartsNote,groupNumber,groupCode,finalPartsImageUrl,finalPartsImageX,finalPartsImageY,finalPartsImageOffsetX,finalPartsImageOffsetY,vehicleCode,count " +
            "FROM hyundai_parts " +
            "WHERE bpno=#{bpno} and groupCode IN " +
            "<foreach item='item' index='index' collection='groupCodes' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    Set<KiaPartsDTO> queryPartCodeByGroupCode(@Param("groupCodes") List<String> groupCodes, @Param("bpno") String bpno);

    @Select("<script>" +
            "SELECT groupCode,finalPartsImageUrl " +
            "FROM hyundai_parts " +
            "WHERE bpno=#{bpno} and (groupCode,groupName) IN " +
            "<foreach item='item' index='index' collection='imageInfo' open='(' separator=',' close=')'>" +
            " (#{item.groupCode},#{item.groupName}) " +
            "</foreach>" +
            "</script>")
    List<KiaPartsDTO> queryPartsByImageInfo(@Param("imageInfo") List<HyundaiKiaImageInfoDTO> imageInfo, @Param("bpno") String bpno);

    @Select("<script>" +
            "SELECT groupCode,finalPartsImageUrl,count " +
            "FROM hyundai_parts " +
            "WHERE bpno=#{bpno} and groupCode IN " +
            "<foreach item='item' index='index' collection='GroupCode' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    List<KiaPartsDTO> queryPartsByGroupCode(@Param("GroupCode") List<String> imageInfo, @Param("bpno") String bpno);

    @Select("<script>" +
            "SELECT startTime,endTime,finalPartsNote,vehicleCode,groupNumber,groupCode,finalPartsImageUrl,finalPartsImageX,finalPartsImageY,finalPartsImageOffsetX,finalPartsImageOffsetY,count " +
            "FROM hyundai_parts " +
            "WHERE finalPartsImageUrl IN " +
            "<foreach item='item' index='index' collection='imageUrls' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    Set<KiaPartsDTO> queryPointByImageUrl(@Param("imageUrls") List<String> imageUrls);

    @Select("<script>" +
            "SELECT groupName,groupCode,sortName " +
            "FROM hyundai_epc_image_info " +
            "WHERE sortName IN " +
            "<foreach item='item' index='index' collection='sortNames' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    Set<HyundaiKiaImageInfoDTO> queryEPCImageInfo(@Param("sortNames") List<String> imageUrls);
}
